package cn.com.infostrategy.ui.sysapp.dictmanager;

import cn.com.infostrategy.to.common.HashVO;
import cn.com.infostrategy.to.common.WLTRemoteException;
import cn.com.infostrategy.ui.common.UIUtil;
import cn.com.infostrategy.ui.mdata.BillListAfterQueryEvent;
import cn.com.infostrategy.ui.mdata.BillListAfterQueryListener;
import cn.com.infostrategy.ui.mdata.BillListPanel;
import cn.com.infostrategy.ui.mdata.BillListSelectListener;
import cn.com.infostrategy.ui.mdata.BillListSelectionEvent;
import cn.com.infostrategy.ui.mdata.styletemplet.t08.AbstractStyleWorkPanel_08;

public class MWFPanel_PubDBdict extends AbstractStyleWorkPanel_08 implements BillListSelectListener, BillListAfterQueryListener {

	private static final long serialVersionUID = 8977548559593259716L;

	@Override
	public String getParentTableTempletcode() {
		return "pub_dbdict_CODE1";
	}

	@Override
	public String getChildTableTempletcode() {
		return "pub_dbdict_cols_CODE1";
	}

	@Override
	public String getParentAssocField() {
		return "id";
	}

	@Override
	public String getChildAssocField() {
		return "dict_id";
	}

	@Override
	public String getBsinterceptor() {
		return null;
	}

	@Override
	public String getCustBtnPanelName() {
		return "cn.com.infostrategy.ui.sysapp.dictmanager.CustBtnPanel_CreateSQL";
	}

	@Override
	public String getUiinterceptor() {
		return null;
	}

	@Override
	public void onBillListSelectChanged(BillListSelectionEvent _event) {
		super.onBillListSelectChanged(_event);

		_event.getCurrSelectedVO().getStringValue("name");

		CustBtnPanel_CreateSQL cbp = (CustBtnPanel_CreateSQL) this.getCustBtnPanel();
		cbp.getCreateSql().setEnabled(true);

		HashVO[] hashvo;
		try {
			hashvo = UIUtil.getHashVoArrayByDS(null, "select count(*) abc from v_pub_systables where tabname='" + _event.getCurrSelectedVO().getStringValue("tablename") + "'");
			String count = hashvo[0].getStringValue("abc");
			if (count.equals("0")) {
				cbp.getCreateTempLate().setEnabled(false);
			} else {
				cbp.getCreateTempLate().setEnabled(true);
			}

		} catch (WLTRemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		//	cbp.getCreateTempLate().setEnabled(true);

	}

	public void onBillListAfterQuery(BillListAfterQueryEvent _event) {
		CustBtnPanel_CreateSQL cbp = (CustBtnPanel_CreateSQL) this.getCustBtnPanel();
		cbp.getCreateSql().setEnabled(false);
		cbp.getCreateTempLate().setEnabled(false);

	}

	@Override
	public void initialize() {
		super.initialize();
		getParent_BillListPanel().addBillListAfterQueryListener(this);
	}

	@Override
	public BillListPanel getParent_BillListPanel() {
		return super.getParent_BillListPanel();
	}

}
